//
//  TimingSettingViewController.m
//  wAudioShare
//
//  Created by Anson on 15-2-6.
//  Copyright (c) 2015年 赵帅. All rights reserved.
//

#import "TimingSettingViewController.h"
#import "MCOptionsSelectView.h"
#import "SceneArmBaseViewController.h"
#import "TimingSettingModel.h"
#import "Utitlity.h"
#import "CalendarHomeViewController.h"

@interface TimingSettingViewController () <UITableViewDataSource, UITableViewDelegate, MCOptionsSelectViewDelegete>
{
    NSString *ipUrl;
    //SceneDeviceType _currentSelectDeviceType;
//    NSArray *_temperatureArray;
//    NSArray *_dimmerLightPercent;
//    NSArray *_funcionOnOff;
//    NSArray *_thermostatAirMode;
//    NSArray *_multiLevelSensorVal;
//    
//    //!*** 条件列表
//    NSArray *_armConditionList;
//    NSArray *_armConditionStateList;
//    
//    UIPickerView *_pickerView_DeviceList;
//    UIPickerView *_pickerView_Switch;
//    UIPickerView *_pickerView_DimmerLight;
//    UIPickerView *_pickerView_Temperature;
//    UIPickerView *_pickerView_ThermostatMode;
//    
//    UIPickerView *_pickerView_ArmConditionList;
//    UIPickerView *_pickerView_ArmStateList;
//    
//    UIPickerView *ios8Picker;
    MCOptionsSelectView *_optionViewWeekDaySelect;
    CalendarHomeViewController *_calendarVC;
}

@property (strong,nonatomic) UITableView *tableView;
@property (strong,nonatomic) TimingSettingModel *settingDataModel;
@property (strong, nonatomic) UIDatePicker *dateTimePicker;

@end

@implementation TimingSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"定时";
    
    CGRect rect = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    self.tableView = [[UITableView alloc] initWithFrame:rect style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:_tableView];    
    
//    UIView *containerV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 200)];
//    CGRect rect = CGRectMake(0, 50, 100, 200);
//    UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:rect];
//    datePicker.datePickerMode = UIDatePickerModeTime;
//    
//    [containerV addSubview:datePicker];
//    
//    self.tableView.tableHeaderView = containerV;
    
    TimingSettingModel *newModel = [[TimingSettingModel alloc] initWithFixedDateTime:[NSDate date]];
    newModel.deviceModel.isOn = YES;
    newModel.type = TimingSettingDeviceTypeNormal;
    self.settingDataModel = newModel;
    _currentSelectDeviceType = [self.deviceData[@"DeviceType"] integerValue];
    if (self.deviceData[@"DeviceType"]) {
        
        if (_currentSelectDeviceType == SceneDeviceTypeBinarySensor
            || _currentSelectDeviceType == SceneDeviceTypeMultilevelSensor) {
            self.settingDataModel.type = TimingSettingDeviceTypeSensorArm;
        }
        self.settingDataModel.deviceModel.deviceType = _currentSelectDeviceType;
        
    }else if (self.deviceData[@"ArmType"]) {
        self.settingDataModel.type = TimingSettingDeviceTypeSensorArm;
    }
    
    if (self.settingDataModel.type == TimingSettingDeviceTypeSensorArm) {
        _funcionOnOff = @[@"ARM", @"Disarm"];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//- (void)viewDidAppear:(BOOL)animated {
//    [super viewDidAppear:animated];
//    [self.tableView reloadData];
//}

#pragma mark - UIButton
- (IBAction)onConfirmAddTimingSettingBtnClicked:(id)sender {
 
    [self reqAddNewTimingSetting:self.deviceData[@"ZID"]];
    
    
}

#pragma mark - Http Request
- (void)reqAddNewTimingSetting:(NSString *)deviceZID {
    self.settingDataModel.date = self.dateTimePicker.date;
    ipUrl = [Utitlity judgeipUrl];
    if (ipUrl) {
        
        [activity startAnimating];
        
        NSString *urlStr = nil;
        switch (_currentSelectDeviceType) {
            case SceneDeviceTypeSwitch:
            case SceneDeviceTypeDimmer:
            case SceneDeviceTypePowerMeter:
            case SceneDeviceTypeMotor:
            {
                if (self.settingDataModel.runType == TimingSettingRunTypeFixedDay) {
                    urlStr = [NSString stringWithFormat:@"http://%@/cgi-bin/Schedule.cgi?action=do_adddate&did=%@&date=%@&cmd=0x25&index=0&value=%d", ipUrl, deviceZID, [TimingSettingModel getDateTimeVal:self.settingDataModel.date], (self.settingDataModel.deviceModel.isOn == YES ? 255 : 0)];
                }else {
                    ASIFormDataRequest *formDataRequest = [ASIFormDataRequest requestWithURL:nil];
                    NSString *encodeTime = [formDataRequest encodeURL:[self.settingDataModel.date stringOfDateWithFormatHHmmss]];
                    urlStr = [NSString stringWithFormat:@"http://%@/cgi-bin/Schedule.cgi?action=do_addweek&did=%@&week=%@&repeat=true&time=%@&cmd=0x25&index=0&value=%d", ipUrl, deviceZID, self.settingDataModel.weeks, encodeTime, (self.settingDataModel.deviceModel.isOn == YES ? 255 : 0)];
                }
                break;
            }                
                
            case SceneDeviceTypeThermostat:
            {
               
                break;
            }
            
            case SceneDeviceTypeBinarySensor:
            case SceneDeviceTypeMultilevelSensor:
            {
                if (self.settingDataModel.runType == TimingSettingRunTypeFixedDay) {
                    urlStr = [NSString stringWithFormat:@"http://%@/cgi-bin/Schedule.cgi?action=do_addarmdate&did=%@&date=%@&arm=%@", ipUrl, deviceZID, [TimingSettingModel getDateTimeVal:self.settingDataModel.date], (self.settingDataModel.deviceModel.isOn == YES ? @"true":@"false")];
                }else {
                    ASIFormDataRequest *formDataRequest = [ASIFormDataRequest requestWithURL:nil];
                    NSString *encodeTime = [formDataRequest encodeURL:[self.settingDataModel.date stringOfDateWithFormatHHmmss]];
                    urlStr = [NSString stringWithFormat:@"http://%@/cgi-bin/Schedule.cgi?action=do_addarmweek&did=%@&week=%@&repeat=true&time=%@&arm=%@", ipUrl, deviceZID, self.settingDataModel.weeks, encodeTime, (self.settingDataModel.deviceModel.isOn == YES ? @"true":@"false")];
                }
                break;
            }
            default:
                break;
        }

        [Utitlity commonHTTPMethod:urlStr responseType:jsonType success:^(AFHTTPRequestOperation *operation, id responseObject) {
            [activity stopAnimating];
            
            if (!responseObject) return;
            NSDictionary *retJsonData = responseObject;
            DLog(@"%@", retJsonData);
            if ( [[[retJsonData objectForKey:@"state"] lowercaseString] isEqualToString:@"success"] ) {
                
                self.settingDataModel.unId = retJsonData[@"data"];
                if (self.didSelectedBlock) {
                    self.didSelectedBlock(_settingDataModel);
                }
                [self.navigationController popViewControllerAnimated:YES];
            }
            
        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
            [activity stopAnimating];
            NSLog(@"error:%@",error);
        }];
        
    }
}


#pragma mark - UITableView
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 250.0;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    UIView *containerV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 200)];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
    titleLabel.text = self.deviceData[@"Alias"];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [containerV addSubview:titleLabel];
    
    CGRect rect = CGRectMake(0, 44, 100, 200);
    UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:rect];
    datePicker.datePickerMode = UIDatePickerModeTime;
    datePicker.date = self.settingDataModel.date;
    self.dateTimePicker = datePicker;
    [containerV addSubview:datePicker];
    return containerV;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 50;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH, 50);
    UIView *container = [[UIView alloc] initWithFrame:rect];
    container.backgroundColor = [UIColor clearColor];

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTitle:@"添加" forState:UIControlStateNormal];
    btn.backgroundColor = [UIColor redColor];
    btn.bounds = CGRectMake(0, 5, 80, 40);
    btn.center = CGPointMake(rect.size.width/2, rect.size.height/2);
    btn.layer.masksToBounds = YES;
    btn.layer.cornerRadius = 0.7;
    [btn addTarget:self action:@selector(onConfirmAddTimingSettingBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
    [container addSubview:btn];
    return container;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell =  [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    switch (indexPath.row) {
        case 0:
        {
            cell.textLabel.text = @"功能";
            NSString *detailText = nil;
            switch (_currentSelectDeviceType) {
                case SceneDeviceTypeSwitch:
                case SceneDeviceTypeDimmer:
                case SceneDeviceTypePowerMeter:
                case SceneDeviceTypeMotor:
                case SceneDeviceTypeThermostat:
                {
                    if (self.settingDataModel && self.settingDataModel.deviceModel) {
                        
                        if (self.settingDataModel.deviceModel.deviceType == SceneDeviceTypeThermostat) {
                            
                            detailText = self.settingDataModel.deviceModel.isOn ? @"ON":@"OFF";
                            detailText = [detailText stringByAppendingFormat:@" %@ %ld℃", self.settingDataModel.deviceModel.mode, self.settingDataModel.deviceModel.thermostatTemperature];
                            
                        }else if (self.settingDataModel.deviceModel.deviceType == SceneDeviceTypeBinarySensor
                                  || self.settingDataModel.deviceModel.deviceType == SceneDeviceTypeMultilevelSensor) {
                          
                             detailText = self.settingDataModel.deviceModel.isOn ? @"ARM":@"Disarm";
                        }else {
                         
                            detailText = self.settingDataModel.deviceModel.isOn ? @"ON":@"OFF";
                        
                        }
                    }else
                        detailText = @"ON";
                    
                    break;
                }
                default:
                    break;
            }
            
            if ([self.deviceData[@"SceneType"] boolValue] == YES) {
                
                detailText = @"启动";
                
            }else if ([self.deviceData[@"ArmType"] boolValue] == YES
                      || (_currentSelectDeviceType == SceneDeviceTypeMultilevelSensor || _currentSelectDeviceType == SceneDeviceTypeBinarySensor)) {
                detailText = self.settingDataModel.deviceModel.isOn ? @"ARM":@"Disarm";
            }
            
            cell.detailTextLabel.text = detailText;
            
            break;
        }
            
        case 1:
        {
            cell.textLabel.text = @"重复";
            if (self.settingDataModel.runType == TimingSettingRunTypeWeek) {
                
                cell.detailTextLabel.text = [TimingSettingModel getDescriptForWeeksVal:[self.settingDataModel.weeks componentsSeparatedByString:@","]];
            }else
                cell.detailTextLabel.text = @"永不";
            
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            break;
        }
            
        case 2:
        {
            cell.textLabel.text = @"日期";
            if (self.settingDataModel.runType == TimingSettingRunTypeFixedDay) {
                cell.detailTextLabel.text = [self.settingDataModel.date stringOfDateWithFormatYYYYMMddLine];
            }else
                cell.detailTextLabel.text = @"";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            break;
        }
            
        default:
            break;
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    switch (indexPath.row) {
        case 0:
        {
            [self doChoose:PICKER_VIEW_FUNCTION_LIST_TAG];
            break;
        }
            
        case 1:
        {
            CGRect rect = CGRectMake(0, 0, self.view.frame.size.width, 200);
            if (!_optionViewWeekDaySelect) {
                _optionViewWeekDaySelect = [[MCOptionsSelectView alloc] initWithFrame:rect delegate:self];
                _optionViewWeekDaySelect.columns = 3;
          
                {
                    [_optionViewWeekDaySelect addOptionItem:[[MCOptionSelectViewItem alloc] initWithTitle:@"每周一" value:@"1"]];
                    [_optionViewWeekDaySelect addOptionItem:[[MCOptionSelectViewItem alloc] initWithTitle:@"每周二" value:@"2"]];
                    [_optionViewWeekDaySelect addOptionItem:[[MCOptionSelectViewItem alloc] initWithTitle:@"每周三" value:@"3"]];
                    [_optionViewWeekDaySelect addOptionItem:[[MCOptionSelectViewItem alloc] initWithTitle:@"每周四" value:@"4"]];
                    [_optionViewWeekDaySelect addOptionItem:[[MCOptionSelectViewItem alloc] initWithTitle:@"每周五" value:@"5"]];
                    [_optionViewWeekDaySelect addOptionItem:[[MCOptionSelectViewItem alloc] initWithTitle:@"每周六" value:@"6"]];
                    [_optionViewWeekDaySelect addOptionItem:[[MCOptionSelectViewItem alloc] initWithTitle:@"每周日" value:@"0"]];
                }
                _optionViewWeekDaySelect.multiSelect = YES;
            }
            
            [_optionViewWeekDaySelect showInView:self.navigationController.view];
            break;
        }
        
        case 2:
        {
            if (!_calendarVC) {
                
                _calendarVC = [[CalendarHomeViewController alloc]init];
                _calendarVC.calendartitle = @"日期选择";
                [_calendarVC setAirPlaneToDay:365 ToDateforString:nil];
            }
            
            __block TimingSettingModel *timingSettingModel = _settingDataModel;
            __block TimingSettingViewController *vc = self;
            _calendarVC.calendarblock = ^(CalendarDayModel *model){
                
                UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
                cell.detailTextLabel.text = [model.date stringOfDateWithFormatYYYYMMddLine];
                
                TimingSettingModel *newModel = [[TimingSettingModel alloc] initWithFixedDateTime:model.date];
                newModel.type = timingSettingModel.type;
                newModel.deviceModel = timingSettingModel.deviceModel;
                vc.settingDataModel = newModel;
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                    [tableView reloadData];
                });
    
            };
            [self.navigationController pushViewController:_calendarVC animated:YES];

            break;
        }
        default:
            break;
    }
    
}

#pragma mark - UIDatePicker Delegate


#pragma mark - WeekDay OptionView Delegate
- (void)theMCOptionsSelectView:(MCOptionsSelectView *)view confirmList:(NSArray *)optionList {
    
    NSMutableArray *titles = [[NSMutableArray alloc] initWithCapacity:5];
    NSMutableArray *list = [[NSMutableArray alloc] initWithCapacity:5];
    for (MCOptionSelectViewItem *item in optionList) {
        
        [list addObject:item.value];
        [titles addObject:item.title];
    }
    
    //NSString *dateTime = [self.dateTimePicker.date stringOfDateWithFormatHHmmss];
    TimingSettingModel *timingSettingData = [[TimingSettingModel alloc] initWithWeek:[list componentsJoinedByString:@","] andTime:self.dateTimePicker.date];
    timingSettingData.type = self.settingDataModel.type;
    timingSettingData.deviceModel = self.settingDataModel.deviceModel;
    self.settingDataModel = timingSettingData;
    
    [self.tableView reloadData];
}

#pragma mark -
- (void)pickerViewConfirmForFunctionList:(NSInteger)picker_selected_index {
    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    switch (_currentSelectDeviceType) {

        case SceneDeviceTypeSwitch:
        case SceneDeviceTypeMotor:
        case SceneDeviceTypePowerMeter:
        case SceneDeviceTypeDimmer:
        {
            self.settingDataModel.deviceModel.isOn = (picker_selected_index == 0);
            cell.detailTextLabel.text = (self.settingDataModel.deviceModel.isOn ? @"ON":@"OFF");
            break;
        }
        case SceneDeviceTypeBinarySensor:
        case SceneDeviceTypeMultilevelSensor:
        {
            self.settingDataModel.deviceModel.isOn = (picker_selected_index == 0);
            cell.detailTextLabel.text = (self.settingDataModel.deviceModel.isOn ? @"ARM":@"Disarm");
            break;
        }
        case SceneDeviceTypeThermostat:
        {
            self.settingDataModel.deviceModel.isOn = (picker_selected_index == 0);
            if (self.settingDataModel.deviceModel.isOn) {
                [self doChoose:PICKER_VIEW_THERMOSTATMODE_TAG];
            }
            //cell.detailTextLabel.text = (self.settingDataModel.deviceModel.isOn ? @"ON":@"OFF");
            break;
        }
        default:
            break;
    }
    
}

- (void)pickerViewConfirmForThermostatmode:(NSInteger)picker_selected_index {
    self.settingDataModel.deviceModel.mode = _thermostatAirMode[picker_selected_index];
    if ([self.settingDataModel.deviceModel.mode.lowercaseString isEqualToString:@"heat"] || [self.settingDataModel.deviceModel.mode.lowercaseString isEqualToString:@"cool"]) {
        [self doChoose:PICKER_VIEW_TEMPERATURE_LIST_TAG];
    }
}

- (void)pickerViewConfirmForTemperature:(NSInteger)picker_selected_index {
    self.settingDataModel.deviceModel.thermostatTemperature = [_temperatureArray[picker_selected_index] integerValue];
    
    NSString *txt = (self.settingDataModel.deviceModel.isOn ? @"ON":@"OFF");
    txt = [txt stringByAppendingFormat:@" %@ ", self.settingDataModel.deviceModel.mode];
    if ([self.settingDataModel.deviceModel.mode.lowercaseString isEqualToString:@"heat"] || [self.settingDataModel.deviceModel.mode.lowercaseString isEqualToString:@"cool"]) {
         txt = [txt stringByAppendingFormat:@"%ld ", self.settingDataModel.deviceModel.thermostatTemperature];
    }
    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    cell.detailTextLabel.text = txt;
    [self.tableView reloadData];
}
/*
- (NSString *)getDescriptForWeeksVal:(NSArray *)weeks {
 
    NSComparator cmptr = ^(id obj1, id obj2){
        if ([obj1 integerValue] > [obj2 integerValue]) {
            return (NSComparisonResult)NSOrderedDescending;
        }
        
        if ([obj1 integerValue] < [obj2 integerValue]) {
            return (NSComparisonResult)NSOrderedAscending;
        }
        return (NSComparisonResult)NSOrderedSame;
    };
    
    NSMutableString *ret = [[NSMutableString alloc] initWithString:@""];
    NSArray *sortArray = [weeks sortedArrayUsingComparator:cmptr];
    for (NSString *item in sortArray) {
        
        switch ([item integerValue]) {
            case 0:
                [ret appendString:@"周日 "];
                break;
            case 1:
                [ret appendString:@"周一 "];
                break;
            case 2:
                [ret appendString:@"周二 "];
                break;
            case 3:
                [ret appendString:@"周三 "];
                break;
            case 4:
                [ret appendString:@"周四 "];
                break;
            case 5:
                [ret appendString:@"周五 "];
                break;
            case 6:
                [ret appendString:@"周六 "];
                break;
            default:
                break;
        }
    }
    return ret;
}

- (NSString *)getDateTimeVal:(NSDate *)date {
    
    if (date) {
        
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        [formatter setDateFormat:@"YYYYMMdd"];
        NSString *str = [formatter stringFromDate:date];
    
        [formatter setDateFormat:@"HHmmss"];
        NSString *str2 = [formatter stringFromDate:date];
        return [str stringByAppendingFormat:@"T%@", str2];
    }
    return @"";
}
*/
/*
- (void)initPickerView {
 
    _funcionOnOff = @[@"ON", @"OFF"];
 
    NSMutableArray *percent = [NSMutableArray arrayWithCapacity:100];
    for (NSInteger i=0; i<=100; i++) {
        [percent addObject:[NSString stringWithFormat:@"%ld%%", i]];
    }
    _dimmerLightPercent = percent;
 
    _thermostatAirMode = @[@"Heat", @"Cool", @"Auto", @"Resume"];
 
    NSMutableArray *list = [NSMutableArray arrayWithCapacity:50];
    for (NSInteger i=-50; i<120; i++) {
        [list addObject:[NSString stringWithFormat:@"%ld", i]];
    }
    _multiLevelSensorVal = list;
    
    _pickerView_DeviceList = [[UIPickerView alloc]initWithFrame:CGRectZero];
    _pickerView_DeviceList.dataSource = self;
    _pickerView_DeviceList.delegate = self;
    _pickerView_DeviceList.tag = PICKER_VIEW_DEVICE_LIST_TAG;
    _pickerView_DeviceList.showsSelectionIndicator = YES;
    
    _pickerView_Switch = [[UIPickerView alloc]initWithFrame:CGRectZero];
    _pickerView_Switch.dataSource = self;
    _pickerView_Switch.delegate = self;
    _pickerView_Switch.tag = PICKER_VIEW_FUNCTION_LIST_TAG;
    _pickerView_Switch.showsSelectionIndicator = YES;
    
    _pickerView_DimmerLight = [[UIPickerView alloc] initWithFrame:CGRectZero];
    _pickerView_DimmerLight.dataSource = self;
    _pickerView_DimmerLight.delegate = self;
    _pickerView_DimmerLight.tag = PICKER_VIEW_FUNCTION_LIST_TAG;
    _pickerView_DimmerLight.showsSelectionIndicator = YES;
    
    _pickerView_Temperature = [[UIPickerView alloc] initWithFrame:CGRectZero];
    _pickerView_Temperature.dataSource = self;
    _pickerView_Temperature.delegate = self;
    _pickerView_Temperature.tag = PICKER_VIEW_TEMPERATURE_LIST_TAG;
    _pickerView_Temperature.showsSelectionIndicator = YES;
    
    _pickerView_ThermostatMode = [[UIPickerView alloc] initWithFrame:CGRectZero];
    _pickerView_ThermostatMode.dataSource = self;
    _pickerView_ThermostatMode.delegate = self;
    _pickerView_ThermostatMode.tag = PICKER_VIEW_THERMOSTATMODE_TAG;
    _pickerView_ThermostatMode.showsSelectionIndicator = YES;
}

//-(void)doChoose:(NSInteger)tag
//{
//    UIPickerView *picker = nil;
//    int index = 0;
//
//    if (tag == PICKER_VIEW_FUNCTION_LIST_TAG)
//    {
//        switch (_currentSelectDeviceType) {
//            case SceneDeviceTypeBinarySensor:
//            case SceneDeviceTypeMultilevelSensor:
//            case SceneDeviceTypeSwitch:
//            case SceneDeviceTypeMotor:
//            case SceneDeviceTypePowerMeter:
//            case SceneDeviceTypeThermostat:
//            case SceneDeviceTypeDoorLock:
//                picker = _pickerView_Switch;
//                break;
//                
//            case SceneDeviceTypeDimmer:
//                picker = _pickerView_DimmerLight;
//                break;
//                
//            default:
//                break;
//        }
//    }else if (tag == PICKER_VIEW_THERMOSTATMODE_TAG) {
//        
//        picker = _pickerView_ThermostatMode;
//    }else if (tag == PICKER_VIEW_TEMPERATURE_LIST_TAG) {
//        picker = _pickerView_Temperature;
//    }
//    
//}
*/
@end
